package com.topc.others.api;

import com.topc.others.model.vo.CompetitionCheckInfoVo;
import com.topc.others.service.ICompetitionInfoService;
import com.topc.others.service.ICompetitionUserMidService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;

@RestController
@RequestMapping("/open/competition")
public class CompetitionOpenController {
    @Autowired
    private ICompetitionInfoService competitionInfoService;

    @Autowired
    private ICompetitionUserMidService competitionUserMidService;

    //获取竞赛题单ID
    @PostMapping("/search-compose-id")
    public Long getComposeIdById(@NotNull Long competitionId){
        return competitionInfoService.getComposeId(competitionId);
    }

    //获取提交权限检查信息
    @PostMapping("/search-check-info")
    public CompetitionCheckInfoVo getCompetitionCheckInfo(@NotNull Long competitionId, @NotNull String userNumber){
        return competitionInfoService.getCompetitionCheckInfo(competitionId,userNumber);
    }

    @PostMapping("/update-score")
    boolean updateScore(String userNumber, Long competitionId, Integer score){
        System.out.println("更新总分");
        return competitionUserMidService.updateScore(userNumber,competitionId,score);
    }
}
